<?php

namespace AdminBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Inflector\Inflector;

/**
 * HuobiAmazingLog
 *
 * @ORM\Table(name="huobi_amazing_log")
 * @ORM\Entity(repositoryClass="AdminBundle\Repository\HuobiAmazingLogRepository")
 */
class HuobiAmazingLog
{
    /**
     * @var string
     *
     * @ORM\Column(name="version", type="string", length=10, nullable=false)
     */
    private $version = '';

    /**
     * @var string
     *
     * @ORM\Column(name="coin", type="string", length=45, nullable=false)
     */
    private $coin = '';

    /**
     * @var integer
     *
     * @ORM\Column(name="time_stamp", type="integer", nullable=false)
     */
    private $timeStamp = '0';

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="coin_time", type="datetime", nullable=false)
     */
    private $coinTime;

    /**
     * @var string
     *
     * @ORM\Column(name="coin_open", type="decimal", precision=32, scale=16, nullable=false)
     */
    private $coinOpen = '0.0000000000000000';

    /**
     * @var string
     *
     * @ORM\Column(name="coin_close", type="decimal", precision=32, scale=16, nullable=false)
     */
    private $coinClose = '0.0000000000000000';

    /**
     * @var string
     *
     * @ORM\Column(name="coin_low", type="decimal", precision=32, scale=16, nullable=false)
     */
    private $coinLow = '0.0000000000000000';

    /**
     * @var string
     *
     * @ORM\Column(name="coin_high", type="decimal", precision=32, scale=16, nullable=false)
     */
    private $coinHigh = '0.0000000000000000';

    /**
     * @var string
     *
     * @ORM\Column(name="coin_amount", type="decimal", precision=32, scale=16, nullable=false)
     */
    private $coinAmount = '0.0000000000000000';

    /**
     * @var string
     *
     * @ORM\Column(name="coin_vol", type="decimal", precision=32, scale=16, nullable=false)
     */
    private $coinVol = '0.0000000000000000';

    /**
     * @var string
     *
     * @ORM\Column(name="coin_count", type="decimal", precision=32, scale=16, nullable=false)
     */
    private $coinCount = '0.0000000000000000';

    /**
     * @var integer
     *
     * @ORM\Column(name="status", type="integer", nullable=false)
     */
    private $status = '0';

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="ctime", type="datetime", nullable=false)
     */
    private $ctime = 'CURRENT_TIMESTAMP';

    /**
     * @var integer
     *
     * @ORM\Column(name="report_type", type="integer", nullable=false)
     */
    private $reportType = '0';

    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;


    public function __construct($data = [], $prefix = '')
    {
        $this->status = 0;
        $this->ctime = new \DateTime();
        if (empty($data)) {
            return;
        }
        foreach ($data as $key => $value) {
            $var_name = Inflector::camelize($prefix . $key);
            if (property_exists($this, $var_name)) {
                $this->$var_name = $value;
            }
        }

    }

    public function toArray()
    {
        return [
            'id' => $this->id,
            'version' => $this->version,
            'coin' => $this->coin,
            'time_stamp' => $this->timeStamp,
            'open' => $this->coinOpen,
            'close' => $this->coinClose,
            'high' => $this->coinHigh,
            'low' => $this->coinLow,
            'vol' => $this->coinVol,
            'amount' => $this->coinAmount,
            'count' => $this->coinCount,
            'report_type' => $this->reportType,
        ];
    }

    public function toJson()
    {
        return json_encode($this->toArray());
    }

    public function toApiJson()
    {
//params:v={消息版本}&id={消息id}&s={xrpusdt交易对}&p={价格}&lt={拉升时间}&nt={通知时间}&type={1:开多,2:开空,3:平多,4:平空,11:买,12:卖}
        $data = [
            'v' => $this->version,
            'id' => $this->id,
            's' => $this->coin,
            'p' => $this->coinClose,
            'lt' => date('Y-m-d H:i:s', $this->timeStamp),
            'nt' => date('Y-m-d H:i:s', time()),
            'type' => $this->reportType,
        ];
        return json_encode($data);
    }

    /**
     * Set coin
     *
     * @param string $coin
     *
     * @return HuobiAmazingLog
     */
    public function setCoin($coin)
    {
        $this->coin = $coin;

        return $this;
    }

    /**
     * Get coin
     *
     * @return string
     */
    public function getCoin()
    {
        return $this->coin;
    }

    /**
     * Set timeStamp
     *
     * @param integer $timeStamp
     *
     * @return HuobiAmazingLog
     */
    public function setTimeStamp($timeStamp)
    {
        $this->timeStamp = $timeStamp;

        return $this;
    }

    /**
     * Get timeStamp
     *
     * @return integer
     */
    public function getTimeStamp()
    {
        return $this->timeStamp;
    }

    /**
     * Set coinTime
     *
     * @param \DateTime $coinTime
     *
     * @return HuobiAmazingLog
     */
    public function setCoinTime($coinTime)
    {
        $this->coinTime = $coinTime;

        return $this;
    }

    /**
     * Get coinTime
     *
     * @return \DateTime
     */
    public function getCoinTime()
    {
        return $this->coinTime;
    }

    /**
     * Set coinOpen
     *
     * @param string $coinOpen
     *
     * @return HuobiAmazingLog
     */
    public function setCoinOpen($coinOpen)
    {
        $this->coinOpen = $coinOpen;

        return $this;
    }

    /**
     * Get coinOpen
     *
     * @return string
     */
    public function getCoinOpen()
    {
        return $this->coinOpen;
    }

    /**
     * Set coinClose
     *
     * @param string $coinClose
     *
     * @return HuobiAmazingLog
     */
    public function setCoinClose($coinClose)
    {
        $this->coinClose = $coinClose;

        return $this;
    }

    /**
     * Get coinClose
     *
     * @return string
     */
    public function getCoinClose()
    {
        return $this->coinClose;
    }

    /**
     * Set coinLow
     *
     * @param string $coinLow
     *
     * @return HuobiAmazingLog
     */
    public function setCoinLow($coinLow)
    {
        $this->coinLow = $coinLow;

        return $this;
    }

    /**
     * Get coinLow
     *
     * @return string
     */
    public function getCoinLow()
    {
        return $this->coinLow;
    }

    /**
     * Set coinHigh
     *
     * @param string $coinHigh
     *
     * @return HuobiAmazingLog
     */
    public function setCoinHigh($coinHigh)
    {
        $this->coinHigh = $coinHigh;

        return $this;
    }

    /**
     * Get coinHigh
     *
     * @return string
     */
    public function getCoinHigh()
    {
        return $this->coinHigh;
    }

    /**
     * Set coinAmount
     *
     * @param string $coinAmount
     *
     * @return HuobiAmazingLog
     */
    public function setCoinAmount($coinAmount)
    {
        $this->coinAmount = $coinAmount;

        return $this;
    }

    /**
     * Get coinAmount
     *
     * @return string
     */
    public function getCoinAmount()
    {
        return $this->coinAmount;
    }

    /**
     * Set coinVol
     *
     * @param string $coinVol
     *
     * @return HuobiAmazingLog
     */
    public function setCoinVol($coinVol)
    {
        $this->coinVol = $coinVol;

        return $this;
    }

    /**
     * Get coinVol
     *
     * @return string
     */
    public function getCoinVol()
    {
        return $this->coinVol;
    }

    /**
     * Set coinCount
     *
     * @param string $coinCount
     *
     * @return HuobiAmazingLog
     */
    public function setCoinCount($coinCount)
    {
        $this->coinCount = $coinCount;

        return $this;
    }

    /**
     * Get coinCount
     *
     * @return string
     */
    public function getCoinCount()
    {
        return $this->coinCount;
    }

    /**
     * Set ctime
     *
     * @param \DateTime $ctime
     *
     * @return HuobiAmazingLog
     */
    public function setCtime($ctime)
    {
        $this->ctime = $ctime;

        return $this;
    }

    /**
     * Get ctime
     *
     * @return \DateTime
     */
    public function getCtime()
    {
        return $this->ctime;
    }

    /**
     * Set version
     *
     * @param string $version
     *
     * @return HuobiAmazingLog
     */
    public function setVersion($version)
    {
        $this->version = $version;

        return $this;
    }

    /**
     * Get version
     *
     * @return string
     */
    public function getVersion()
    {
        return $this->version;
    }

    /**
     * Set status
     *
     * @param integer $status
     *
     * @return HuobiAlertSender
     */
    public function setStatus($status)
    {
        $this->status = $status;

        return $this;
    }

    /**
     * Get status
     *
     * @return integer
     */
    public function getStatus()
    {
        return $this->status;
    }

    /**
     * Set reportType
     *
     * @param integer $reportType
     *
     * @return HuobiAlertSender
     */
    public function setReportType($reportType)
    {
        $this->reportType = $reportType;

        return $this;
    }

    /**
     * Get reportType
     *
     * @return integer
     */
    public function getReportType()
    {
        return $this->reportType;
    }

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }
}
